<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("utf-8"); %>
<!DOCTYPE html>
<html>
<head>
<script src="${pageContext.request.contextPath }/se2/js/HuskyEZCreator.js" type="text/javascript" charset="utf-8"></script>
<!-- 이미지 업로드 관련 js파일 -->
<script src="${pageContext.request.contextPath }/se2/photo_uploader/plugin/hp_SE2M_AttachQuickPhoto.js" type="text/javascript" charset="utf-8"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
	body {
	font-family: '나눔고딕';
	font-size: 14px;
	font-weight: bold;
	color: red;
	margin-top: 100px;
	background-image: url('../../images/main.jpg');
	background-size: 55% 57%;
	}
	.bw_btn{
		background-color: black;
		color: red;
		font-weight: bold;
		font-size: 15px;
	}
	.b_tb{
		background-color: black;
	}
	.bw_td{
		color: red;
		font-weight: bold;
		font-size: 20px;
	}
</style>
<script type="text/javascript">
	function fnWrite(frm) {
		if(frm.mid.value == ""){
			alert("아이디를 입력해주세요!");
			frm.mid.focus();
			return false;
		}
		if(frm.pwd.value == ""){
			alert("암호를 입력해주세요!");
			frm.pwd.focus();
			return false;
		}
		if(frm.title.value == ""){
			alert("제목을 입력해주세요!");
			frm.title.focus();
			return false;
		}
		
		//js파일에 있는 펑션 이용해서 스마트 에디터의 값을 가져와
		//BBSVo의 변수명과 동일한 content에 넣어줌
		//그래야지 BWResult에서 유즈빈태그를 이용해서 값을 받을수있음
		var sHTML = oEditors.getById["textAreaContent"].getIR();
		
		frm.content.value=sHTML;
		frm.submit();
	}
</script>
</head>
<body>
	<form action="${pageContext.request.contextPath }/homepage/bbs/BWResult.jsp" method="post" onsubmit="return fnWrite(this)">
		<div align="center" id="bw_div">
			<h1>글 쓰기</h1>
			<table class="b_tb" width="75%">
				<tr>
					<td class="bw_td">작성자</td>
					<td>
						<input type="text" name="mid" id="mid">
					</td>
					<td width="50px;"></td>
				</tr>
				<tr>
					<td class="bw_td">암호</td>
					<td>
						<input type="password" name="pwd" id="pwd">
					</td>
					<td width="50px;"></td>
				</tr>
				<tr>
					<td class="bw_td">제목</td>
					<td><input type="text" size="100" name="title" id="title"></td>
				</tr>
				<tr>
					<td class="bw_td">내용</td>
					<td bgcolor="#ffffff">
						<textarea name="content" id="textAreaContent" style="width: 100%;" rows="40" cols="80"></textarea>
					</td>
				</tr>
			</table>
			<table width="75%" class="b_tb">
				<tr>
					<td align="right">
							<input type="submit" value="글쓰기" id="btnWrite" class="bw_btn" >
						<input type="button" value="다시 작성" id="btnReset" class="bw_btn">
						<a href="javascript:onclick=history.back();">
							<input type="button" value="취소" id="btnCancel" class="bw_btn"></a>
						<a href="#">
							<input type="button" value="목록" id="btnList" class="bw_btn"> </a>
					</td>
					<td width="50px;"></td>
				</tr>
			</table>
			
		</div>
	</form>
	<script type="text/javascript">
		
		//스마트 에디터 붙이는 부분
		var oEditors = [];
		nhn.husky.EZCreator.createInIFrame({
		    oAppRef: oEditors,
		    elPlaceHolder: "textAreaContent",
		    sSkinURI: "${pageContext.request.contextPath }/se2/SmartEditor2Skin.html",
		    fCreator: "createSEditor2"
		});
		// textArea에 이미지 첨부
		function pasteHTML(filepath){
		    var sHTML = '<img src="${pageContext.request.contextPath }/se2/upload/'+filepath+'">';
		    oEditors.getById["textAreaContent"].exec("PASTE_HTML", [sHTML]); 
		}
	</script>
</body>
</html>